import time


import allure
from selenium.webdriver.common.by import By
from base.webkeys import WebKeys
from locator.allPages_data import *


class Customer_listPage(WebKeys):
    def customer_type(self):
        with allure.step("点击客户tab"):
            self.on_click(*the_Customer_tab)
        with allure.step("按业务开发、交易转账、基础属性筛选项进行筛选客户"):
            with allure.step("点击“业务开发”筛选项"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div/div[1]/div')
                self.locator_with_wait(*locator).click()
            with allure.step("点击“业务开发”中的“新开户”"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div[2]/div[5]/div[2]/div[2]/button[1]')
                self.locator_with_wait(*locator).click()
            with allure.step("点击“交易转账”筛选项"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div[2]/div[2]/div')
                self.locator_with_wait(*locator).click()
            with allure.step("点击“交易转账”中的“期货交易”"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div[2]/div[6]/div[3]/div/button[2]')
                self.locator_with_wait(*locator).click()
            with allure.step("点击“基础属性”筛选项"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div[2]/div[3]/div')
                self.locator_with_wait(*locator).click()
            with allure.step("点击“基础属性”中的“线下”"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div[2]/div[7]/div[9]/div/button[2]')
                self.locator_with_wait(*locator).click()
            with allure.step("点击确认选择按钮"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div[2]/div[9]/button[2]/div[1]')
                self.locator_with_wait(*locator).click()

    def customer_list(self):
        # 断言
        with allure.step("判断客户李四成功显示在页面"):
            locator = ("xpath", "//*[text()='李四']")
            result=self.get_text(*locator)
        return result

    def customer_phone(self):
        # 断言
        time.sleep(6)
        with allure.step("判断客户李四成功拉起电话操作"):
            with allure.step("点击电话图标"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[3]/div/div[2]/div[1]/div[4]/i')
                self.locator_with_wait(*locator).click()
            result=self.get_text(*locator)
        return result

    def customer_search(self):
        with allure.step("点击客户tab"):
            self.on_click(*the_Customer_tab)
        with allure.step("按客户信息查询客户"):
            with allure.step("点击“客户信息”筛选项"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div/div[4]/div')
                self.locator_with_wait(*locator).click()
            with allure.step("输入“客户名称”吴六"):
                #id动态变化，选择css选择器
                locator = ( "css selector", "input.var-input__input[type='text']")
                self.locator_with_wait(*locator).send_keys("吴六")
            with allure.step("点击确认选择按钮"):
                locator = ("xpath", '//*[@id="index"]/div[2]/div/div[3]/div/div[1]/div[2]/div[10]/button[2]/div[1]')
                self.locator_with_wait(*locator).click()
        # 断言
        with allure.step("判断客户吴六成功显示在页面"):
            locator = ("xpath", "//*[text()='吴六']")
            result=self.get_text(*locator)
        return result